home *** CD-ROM | disk | FTP | other *** search
- /* MyTextEdit.c
- * Useful utility routines for TextEdit in Writeswell Jr.
- * Copyright ©1993 Working Software, Inc. All Rights Reserved.
- * 4 Mar 93 Mike Crawford
- */
-
- #include "Scroll.h"
- #include "MyTextEdit.h"
- #include "ArrowKeyCodes.h"
-
- void MyTEKey( WindowPtr docWindow,
- ControlHandle vertScroll,
- char theChar,
- Boolean readOnly )
- {
- TEHandle textH;
- short numLines;
- short selStart;
- Rect viewRect;
- Point selPoint;
- Boolean inRect;
-
- textH = (TEHandle)GetWRefCon( docWindow );
-
- numLines = (*textH)->nLines;
-
- if ( readOnly ){
-
- /* We allow the cursor keys to be entered */
-
- switch ( theChar ){
- case kLeftArrow:
- case kRightArrow:
- case kUpArrow:
- case kDownArrow:
- break;
- default:
- return;
- }
- }
-
- TEKey( theChar, textH );
-
- selStart = (*textH)->selStart;
-
- viewRect = (*textH)->viewRect;
-
- selPoint = TEGetPoint( selStart, textH );
-
- inRect = PtInRect( selPoint, &viewRect );
-
- if ( !inRect || numLines != (*textH)->nLines ){
- /* We may need to reset the scroll bar if we changed the number of lines */
- ShowSelection( textH );
- SetVertScroll( docWindow, vertScroll );
- }
-
- return;
- }
-
- TEHandle GetTextHandle( WindowPtr theWindow )
- {
- return (TEHandle)GetWRefCon( theWindow );
- }
-